package com.fs.jzzn.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import lombok.extern.log4j.Log4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.fs.base.vo.Combobox;
import com.fs.base.vo.JsonResponse;
import com.fs.jzzn.pojo.Materiel;
import com.fs.jzzn.repository.MaterielRepository;

/**
 * 物料管理Controller
 * @author ACE
 *
 */
@Log4j
@Controller
@RequestMapping("/console/materiel/rewrite")
public class MaterielController {
	@Autowired private MaterielRepository materielRepository;
	
	@ResponseBody
	@RequestMapping( "/batchImport")
	public JsonResponse batchImport(HttpServletRequest request) {
		return null;
	}
	
	
	@ResponseBody
	@RequestMapping("combobox")
	public Object combobox(Combobox combobox , HttpServletRequest req){
		try {
			List<Materiel> list = materielRepository.findAllUnit();
			combobox = Combobox.builder(list, combobox);
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
		}
		return combobox.getData();
	}
}
